package com;

import com.tecit.TFORMer.*;
import com.tecit.TFORMer.Enumerations.*;
import com.tecit.TFORMer.Printing.JobDataRecordSet;
import com.tecit.TFORMer.Printing.Job;
import com.tecit.TFORMer.Printing.JobDataRecordSet.Record;

public class TestJTFORMer {
	
	public static void main(String[] args) {
		
		// PNO12（基本车型）=车系（3位）+发动机型号（2位）+销售版本（2位）+年款（1位）+变速箱（1位）+左/右舵（1位）+市场代码（2位）
		
		String pno12 = "CX6123ASD897";
		String saleVer = pno12.substring(5, 7);
		String yearCode = pno12.substring(7, 8);
		String gearbox =  pno12.substring(8, 9);
		String lr = pno12.substring(9, 10);
		String marketCode = pno12.substring(10, 12);
		
		
		System.out.println(saleVer);
		System.out.println(yearCode);
		System.out.println(gearbox);
		System.out.println(lr);
		System.out.println(marketCode);
		
//		try {
//			TestJTFORMer.printWithJTFORMer();
//		} catch (TFormerException e) {
//			e.printStackTrace();
//		}
	}

	public static void printWithJTFORMer() throws TFormerException {
		Job job = new Job();
		JobDataRecordSet jobdata = new JobDataRecordSet();
		try {
			// connect the jobdata with the job
			job.setJobData(jobdata);
			// select the form layout to be printed/generated,
			// adjust the type and name of the output
			job.setRepositoryName("f:\\aaa.tff");
			job.setOutputName("F:\\output.jpg");
			job.setPrinterType(EPrinterType.ImageJpg);
			// provide data for the datafields used in the form layout
			Record record = new JobDataRecordSet.Record();
			record.setData("AddressLine1_TO", "陶爱军");
			record.setData("AddressLine2_TO", "王yibo");
			record.setData("SED", "213123");
			record.setData("LabelServiceCode", "123456789");
			jobdata.add(record);
			// finally print it
			job.print();
		} catch (TFormerException ex) {
			throw ex;
		} finally {
			// dispose ALWAYS the resources in order to free the TFORMer SDK resources
			job.dispose();
			job = null;
		}

	}
}
